home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 54203 / 54203.xpi / chrome / content / uploadpieSearch.js < prev    next >
Text File  |  2009-12-10  |  2KB  |  46 lines

  1. if(!com) var com = {};
  2. if(!com.uploadpie) com.uploadpie = {};
  3. if(!com.uploadpie.uploadpie_fox) com.uploadpie.uploadpie_fox = {};
  4.  
  5. com.uploadpie.uploadpie_fox = {
  6.  
  7.     uploadpie_URL: "http://uploadpie.com",
  8.     targetURL: '',
  9.  
  10.     copyToClip: function(url) {
  11.         const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
  12.         gClipboardHelper.copyString(url);
  13.     },
  14.  
  15.     showImageContext: function() {
  16.         var uploadpie_fox = com.uploadpie.uploadpie_fox;
  17.         document.getElementById("context-uploadpie-search").hidden = true;
  18.         if(gContextMenu.onImage) {
  19.             uploadpie_fox.targetURL = gContextMenu.mediaURL;
  20.             if(!uploadpie_fox.targetURL) {
  21.                 uploadpie_fox.targetURL = gContextMenu.imageURL;
  22.             }
  23.             document.getElementById("context-uploadpie-search").hidden = false;
  24.         }
  25.     },
  26.  
  27.     showImageInit: function() {
  28.         var menu = document.getElementById("contentAreaContextMenu");
  29.         menu.addEventListener("popupshowing", com.uploadpie.uploadpie_fox.showImageContext, false);
  30.     },
  31.  
  32.     uploadpieSearch: function(expire) {
  33.         var uploadpie_fox = com.uploadpie.uploadpie_fox;
  34.         if(!uploadpie_fox.targetURL) return;
  35.         var location = uploadpie_fox.uploadpie_URL + '/extension.php?&url=' + encodeURIComponent(uploadpie_fox.targetURL) + '&expire=' + expire;
  36.         gBrowser.selectedTab = gBrowser.addTab(location);
  37.         var newTab = gBrowser.getBrowserForTab(gBrowser.selectedTab);
  38.         newTab.addEventListener("load", function() {
  39.             uploaded = content.document.getElementById("uploaded").value;
  40.             uploadpie_fox.copyToClip(uploaded);
  41.         }, true); 
  42.         uploadpie_fox.targetURL = ''; // Reset
  43.     }
  44. }
  45.  
  46. window.addEventListener("load", com.uploadpie.uploadpie_fox.showImageInit, false);